<?php
/**
 * @Author: xuzhiyi
 * @Date:   2016-02-16 20:57:18
 * @Last Modified by:   xuzhiyi
 * @Last Modified time: 2016-02-27 11:48:52
 * ------------------------------------------------ *
 * 友情链接                                         *
 * ------------------------------------------------ */

namespace Admin\Controller;
class FriendlinksController extends CommonController {


	public function index(){
		if(IS_AJAX){
			switch(I('ajax')){
				
				case "addFriendlinks":
					$a = D('Friendlinks')->addFriendlinks();
					if($a){
						$this->success('友情链接添加成功！','',true);	
					}
					$this->error('友情链接添加失败！','',true);
					break;
				case "delFriendlinks":
					$status = D('Friendlinks')->delFriendlinks();
					$this->ajaxReturn($status);
					break;
				case "editFriendlinks":
					$a = D('Friendlinks')->editFriendlinks();
					if($a){
						$this->success('友情链接修改成功！','',true);	
					}
					$this->error('友情链接修改失败！','',true);
					break;
				default:
			 		$rs = M('friendlinks')->select();
			 		$result = array();
			 		foreach($rs as $val){
			 			$val['ac']='';
			 			$result[]=$val;
			 		}
			 		$output['data'] = $result;
			 		$this->ajaxReturn($output);
			}
		}
		$this->display();
	}



}